var app = angular.module('webapp');

app.service('HomeService', ['$http','$q', HomeService])

function HomeService($http , $q){

	function handleRequest(method , url , data){
		var defered = $q.defer();

		var config = {
			method : method,
			url : url
		};

		if('POST' == method){
			config.data = data;
		}else if('GET' == method){
			config.params = data;
		}

		$http(config).success(function(result){
			defered.resolve(result);
		}).error(function(err){
			defered.reject(err);
		});

		return defered.promise;
	}

	return {
		getImgByPlace:function(data){
			return handleRequest('GET','/getImgByPlace',data);
		},
		getHomeMenu:function(data){
			return handleRequest('GET','/getHomeMenu',data);
		}
	}
}